Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add CMake-based build system (4 of N) #10

Merged
merged 6 commits into from
Mar 31, 2023
Merged

Conversation

hebasto
Copy link
Owner

@hebasto hebasto commented Feb 24, 2023

#7 (comment):

So.. requesting a hookup to depends in the next PR please :)

Delivered :)


The parent PR: bitcoin#25797.
The previous PRs in the staging branch: #5, #6, #7.


EXAMPLES:

Cross-compiling for Windows:

make -C depends HOST=x86_64-w64-mingw32 NO_QT=1 NO_WALLET=1 NO_ZMQ=1 NO_UPNP=1 NO_NATPMP=1 NO_USDT=1
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=depends/x86_64-w64-mingw32/share/toolchain.cmake
cmake --build build

Cross-compiling for macOS, arm64:

make -C depends HOST=arm64-apple-darwin NO_QT=1 NO_WALLET=1 NO_ZMQ=1 NO_UPNP=1 NO_NATPMP=1 NO_USDT=1
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=depends/arm64-apple-darwin/share/toolchain.cmake
cmake --build build

@hebasto hebasto force-pushed the 230224-cmake-D branch 5 times, most recently from 101ace5 to 301c5a1 Compare March 2, 2023 00:07
@hebasto hebasto marked this pull request as ready for review March 2, 2023 00:08
@hebasto
Copy link
Owner Author

hebasto commented Mar 2, 2023

Rebased and ready for reviewing :)

Copy link

@theuni theuni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High-level review comments/questions.

depends/Makefile Outdated
-e 's|@CMAKE_INSTALL_NAME_TOOL@|$(host_INSTALL_NAME_TOOL)|' \
-e 's|@OTOOL@|$(host_OTOOL)|' \
-e 's|@CMAKE_FIND_ROOT_PATH@|$(host_prefix)|' \
-e 's|@CMAKE_C_FLAGS_INIT@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS) $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, I don't like the idea of doing CMake logic here. In this case, we're combining a set of flags without giving CMake the opportunity to do so itself.

I think we actually want to export to abstract vars instead, then set those vars to CMake vars inside the toolchain file.

So instead of:

's|@CMAKE_CXX_FLAGS_INIT@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS) $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|'

Have:

's|@DEPENDS_CPPFLAGS@|$(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|'
's|@DEPENDS_CXXFLAGS@|$(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|'

Then allow the CMake file to decide `CMAKE_CXX_FLAGS_INIT = DEPENDS_CPPFLAGS + DEPENDS_CXXFLAGS.

Same goes for all vars. I don't think the CMAKE_ prefix belongs here.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Updated.

set(${compiler} ${${compiler}} PARENT_SCOPE)
endfunction()

if(NOT CMAKE_C_COMPILER)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you give a hint as to what's going on here? I'm a little lost :)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to handle every "compiler invocation command", which we have in our build and test environment, properly. Including such cases as follows:

The main part is done in the split_compiler_launcher() function, which splits env -u LIBRARY_PATH clang in env -u LIBRARY_PATH and clang.

Rest of code makes it compatible with the supported range of CMake versions.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this prohibit the use of CMAKE_CXX_COMPILER_LAUNCHER for ccache?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this prohibit the use of CMAKE_CXX_COMPILER_LAUNCHER for ccache?

The future use of CMAKE_{C,CXX}_COMPILER_LAUNCHER with ccache can be peeked in bitcoin@6f48c34.

@@ -98,6 +98,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_compile_definitions(MAC_OSX)
endif()

if(CMAKE_CROSSCOMPILING AND DEPENDS_ALLOW_HOST_PACKAGES)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be done in the toolchain file by conditionally setting the CMAKE_FIND_ROOT_PATH_* vars?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my initial idea as well :)

It turns out that a toolchain file is being processed more than once (the actual number of runs depends on CMake version). Therefore, its processing must be idempotent. list(APPEND ...) command is not idempotent. That is why it has been moved out of the toolchain file.

@TheCharlatan
Copy link

I followed the build instructions and got the following warning:

CMake Warning at CMakeLists.txt:179 (message):
  PIE link options are not supported for executable targets: PIE and NO_PIE
  are not supported by linker for CXX.

Later, during the build, I get linker errors. Might this be a problem with the linker definition, or is something in my toolchain very broken? For what it's worth I can still produce cross-compiled windows binaries in the same environment using the legacy system.

@theuni
Copy link

theuni commented Mar 2, 2023

FYI the --toolchain argument wasn't introduced until 3.21. Frustratingly, when using older CMake it's just quietly ignored and build fails.

Instead, please recommend using -DCMAKE_TOOLCHAIN_FILE.

@theuni
Copy link

theuni commented Mar 2, 2023

I followed the build instructions and got the following warning:

CMake Warning at CMakeLists.txt:179 (message):
  PIE link options are not supported for executable targets: PIE and NO_PIE
  are not supported by linker for CXX.

Later, during the build, I get linker errors. Might this be a problem with the linker definition, or is something in my toolchain very broken? For what it's worth I can still produce cross-compiled windows binaries in the same environment using the legacy system.

Yeah, the logic for PIE isn't quite right. For some systems (win32/macos) position independent code is the default (or even the only supported method). For those platforms passing pic/pie options is either a warning or an error.

So NOT CMAKE_CXX_LINK_PIE_SUPPORTED isn't necessarily something worth warning about. It just means that we shouldn't explicitly add the options:

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14)
  include(CheckPIESupported)
  check_pie_supported(OUTPUT_VARIABLE check_pie_output LANGUAGES CXX)
  if(CMAKE_CXX_LINK_PIE_SUPPORTED)
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  endif()
else()
  # Needs a compile/link test for old cmake
  if(test success)
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  endif()
endif()

@theuni
Copy link

theuni commented Mar 2, 2023

Also, PIE support needs CMP0083, which seems to be missing. I thought we already added that?

Edit: nm, I see that's covered by cmake_minimum_required.

@theuni
Copy link

theuni commented Mar 10, 2023

Ping? :)

@hebasto
Copy link
Owner Author

hebasto commented Mar 10, 2023

FYI the --toolchain argument wasn't introduced until 3.21. Frustratingly, when using older CMake it's just quietly ignored and build fails.

Instead, please recommend using -DCMAKE_TOOLCHAIN_FILE.

Thanks! The PR description has been updated.

@hebasto
Copy link
Owner Author

hebasto commented Mar 10, 2023

@TheCharlatan

I followed the build instructions and got the following warning:

CMake Warning at CMakeLists.txt:179 (message):
  PIE link options are not supported for executable targets: PIE and NO_PIE
  are not supported by linker for CXX.

Later, during the build, I get linker errors. Might this be a problem with the linker definition, or is something in my toolchain very broken? For what it's worth I can still produce cross-compiled windows binaries in the same environment using the legacy system.

Hmm... I'm not able to reproduce any errors. Mind providing more details about your toolchain please?

Also, please ensure your build directory is clean before building starts.

@hebasto
Copy link
Owner Author

hebasto commented Mar 10, 2023

Addressed @theuni's #10 (comment).

@hebasto
Copy link
Owner Author

hebasto commented Mar 11, 2023

Ping? :)

@theuni @TheCharlatan

I apologize for introducing some disruption into our reviewing process.

@theuni
Copy link

theuni commented Mar 11, 2023

I apologize for introducing some disruption into our reviewing process.

No worries! I know you were busy with secp. I just didn't want this process to lose its momentum :)

@TheCharlatan
Copy link

Hmm... I'm not able to reproduce any errors. Mind providing more details about your toolchain please?

Huh, I'm no longer getting the PIE warnings, just the linker errors now. Maybe it is missing a -lpthread somewhere? Small excerpt of errors:

/usr/bin/x86_64-w64-mingw32-ld: libbitcoin_node.a(init.cpp.obj):init.cpp:(.text+0x34): undefined reference to `std::thread::_State::~_State()'
/usr/bin/x86_64-w64-mingw32-ld: libbitcoin_node.a(init.cpp.obj):init.cpp:(.text+0x145e): undefined reference to `std::thread::_State::~_State()'

I'm running a standard install of ubuntu 22 and this mingw32 gcc:

x86_64-w64-mingw32-gcc (GCC) 10-win32 20220113
x86_64-w64-mingw32-g++-posix (GCC) 10-posix 20220113

The summary of configuration options is:

Configure summary
=================
Executables:
  bitcoind ............................ ON

Cross compiling ....................... TRUE, for Windows, x86_64
Preprocessor defined macros ........... _WIN32_WINNT=0x0601 _WIN32_IE=0x0501 WIN32_LEAN_AND_MEAN NOMINMAX WIN32 _WINDOWS _MT
C compiler ............................ /usr/bin/x86_64-w64-mingw32-gcc
CFLAGS ................................ -pipe -std=c11 -O2
C++ compiler .......................... /usr/bin/x86_64-w64-mingw32-g++-posix
CXXFLAGS .............................. -pipe -std=c++17 -O2
Common compile options ................ 
Common link options ................... -Wl,--major-subsystem-version,6 -Wl,--minor-subsystem-version,1
Build type:
 - CMAKE_BUILD_TYPE ................... 
 - CFLAGS ............................. 
 - CXXFLAGS ........................... 
 - LDFLAGS for executables ............ 
 - LDFLAGS for shared libraries ....... 
Use assembly routines ................. ON

Also, please ensure your build directory is clean before building starts.

Yes :)

@hebasto
Copy link
Owner Author

hebasto commented Mar 12, 2023

@TheCharlatan

I've managed to reproduce the linker error you reported. Moreover, it is reproducible even with bitcoin#25797 (

My test environment:

$ cat /etc/os-release | grep PRETTY_NAME
PRETTY_NAME="Ubuntu 20.04.5 LTS"
$ cmake --version | head -1
cmake version 3.16.3
$ /usr/bin/x86_64-w64-mingw32-g++-posix --version | head -1
x86_64-w64-mingw32-g++-posix (GCC) 9.3-posix 20200320

Must be squashed with the commit 91f28a6
"cmake: Add root `CMakeLists.txt` file".
Must be squashed with the commit eb3546f
"cmake: Build `secp256k1` static library".
@hebasto
Copy link
Owner Author

hebasto commented Mar 12, 2023

@TheCharlatan

Later, during the build, I get linker errors.

Fixed.

Huh, I'm no longer getting the PIE warnings...

check_pie_supported is omitted now when CMAKE_CROSSCOMPILING.

@TheCharlatan
Copy link

Fixed.

Thanks, can confirm that it's building fine now.

@theuni
Copy link

theuni commented Mar 24, 2023

@theuni

@hebasto How about addressing the feedback so far

Sorry if I missed some comments unresolved. Which ones are in your mind?

Ah, sorry, I hadn't seen your updates from today before commenting.

Will pick up review next week, hopefully we can agree on a quick merge :)

@hebasto
Copy link
Owner Author

hebasto commented Mar 28, 2023

... hopefully we can agree on a quick merge :)

Still expecting from fellow reviewers for a few formal (conditional?) ACKs or comments that need to be addressed here.

For your information, after merging this PR, I'm planning to rebase the staging branch (similar to #8) and squash "FIXUP" commits from this PR with the commits they are supposed to amend.

@theuni
Copy link

theuni commented Mar 30, 2023

ACK b0351e3, with the caveat that I hope we can make significant changes to the toolchain.cmake.in. But I'm ok calling that a work-in-progress while the rest of the work is introduced to keep it from holding up review further.

@theuni
Copy link

theuni commented Mar 31, 2023

@hebasto Want to go ahead and open the next one based on this one while we wait for another ACK or two here?

It might be helpful to get some more of the depends interactions hooked up as a next step like @TheCharlatan suggested. But if you have another path in mind that's fine by me too.

@hebasto hebasto merged commit 9ca3578 into cmake-staging Mar 31, 2023
@hebasto
Copy link
Owner Author

hebasto commented Mar 31, 2023

Want to go ahead..?

Sure :)

For your information, after merging this PR, I'm planning to rebase the staging branch (similar to #8) and squash "FIXUP" commits from this PR with the commits they are supposed to amend.

See #11.

@hebasto
Copy link
Owner Author

hebasto commented Apr 2, 2023

@theuni

It might be helpful to get some more of the depends interactions hooked up as a next step like @TheCharlatan suggested. But if you have another path in mind that's fine by me too.

I've rebased the parent PR on top of the #11.

Feel free to point any commits you want to see as a next step, in addition to the dependency interactions :)

UPD. See #12

hebasto added a commit that referenced this pull request Apr 19, 2023
8ee7537 cmake: Add `systemtap-sdt` optional package support (Hennadii Stepanov)
697c397 cmake: Add `libzmq` optional package support (Hennadii Stepanov)
b195c9c cmake: Add `libminiupnpc` optional package support (Hennadii Stepanov)
9587ed7 cmake: Add `libnatpmp` optional package support (Hennadii Stepanov)
ba50cad [FIXUP] cmake: Fix `check_evhttp_connection_get_peer` macro (Hennadii Stepanov)
9412a2e [FIXUP] cmake: Cleanup `AddBoostIfNeeded` module (Hennadii Stepanov)
15bcb8e cmake: Add `ccache` support (Hennadii Stepanov)
480c8cb cmake: Add `TristateOption` module (Hennadii Stepanov)

Pull request description:

  It was [suggested](#10 (comment)):

  > It might be helpful to get some more of the depends interactions hooked up as a next step

  Done in this PR.

  ---

  The parent PR: bitcoin#25797.
  The previous PRs in the staging branch: #5, #6, #7, #10.

  ---

  EXAMPLES:

  1. Cross-compiling for Windows:
  ```
  make -C depends HOST=x86_64-w64-mingw32 NO_QT=1 NO_WALLET=1
  cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=depends/x86_64-w64-mingw32/share/toolchain.cmake
  cmake --build build
  ```

  2. Cross-compiling for macOS (`arm64`, `x86_64`):
  ```
  make -C depends HOST=arm64-apple-darwin NO_QT=1 NO_WALLET=1
  cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=depends/arm64-apple-darwin/share/toolchain.cmake
  cmake --build build
  ```

  3. Building on macOS, arm64:
  - essential build tools:
  ```
  brew install cmake pkg-config
  ```
  - optional build tools:
  ```
  brew install ccache
  ```
  - essential dependencies:
  ```
  brew install boost libevent
  ```
  - optional dependencies:
  ```
  brew install libnatpmp miniupnpc zeromq
  ```
  - configure and build:
  ```
  cmake -S . -B build
  cmake --build build
  ```

  4. Building on Windows:

  - `ccache` is available [here](https://community.chocolatey.org/packages/ccache) or [here](https://ccache.dev/download.html) (also see a [note](#13 (comment))):
  ```
  choco install ccache --version=4.7.4
  ```

  - the [`vcpkg`](https://vcpkg.io) package manager is used to provide other dependencies:
  ```
  vcpkg --triplet=x64-windows-static install boost-multi-index boost-signals2 libevent miniupnpc zeromq
  ```

  - configure and build:
  ```
  cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
  cmake --build build -- -property:UseMultiToolTask=true -maxCpuCount
  ```

  ---

  **NOTE**

  As always, make sure your build tree is clean :)

ACKs for top commit:
  vasild:
    ACK 8ee7537
  theuni:
    ACK 8ee7537

Tree-SHA512: 36ebc63e73d507d86b154121b9bc5b8216554fd63f31808f257cefff7a1a104ce066f2b2cf9fdfc1828066d33cdc0b9ede4a81d8e6a7932de3adcb1f14674796
@willcl-ark
Copy link

@hebasto wondering if there are plans to add automatic depends configuration to bitcoin configure (if depends/${host}/share/config.site exists, à la bitcoin#16692 (comment)) as part of this re-write?

@hebasto
Copy link
Owner Author

hebasto commented May 1, 2023

@willcl-ark

wondering if there are plans to add automatic depends configuration to bitcoin configure (if depends/${host}/share/config.site exists, à la bitcoin#16692 (comment)) as part of this re-write?

I no longer consider this feature as a useful one due to the case, which is actually an everyday workflow for me, when the user has depends built for many hosts simultaneously.

hebasto pushed a commit that referenced this pull request May 2, 2023
f952e67 ci: remove usage of untrusted bpfcc-tools (fanquake)
1232c2f ci: use LLVM/clang-16 in native_asan job (fanquake)

Pull request description:

  Similar to bitcoin#27298. Working for me on `x86_64` and solves the issue I currently see with TSAN on `aarch64` with master (6882828):
  ```bash
  crc32c/src/crc32c_arm64.cc:101:26: runtime error: load of misaligned address 0xffff84400406 for type 'uint64_t' (aka 'unsigned long'), which requires 8 byte alignment
  0xffff84400406: note: pointer points here
   b9 c5 22 00 01 01  1a 6c 65 76 65 6c 64 62  2e 42 79 74 65 77 69 73  65 43 6f 6d 70 61 72 61  74 6f
               ^
      #0 0xaaaaaddaf0b4 in crc32c::ExtendArm64(unsigned int, unsigned char const*, unsigned long) src/./src/crc32c/src/crc32c_arm64.cc:101:26
      #1 0xaaaaadd2c838 in leveldb::crc32c::Value(char const*, unsigned long) src/./leveldb/util/crc32c.h:20:60
      #2 0xaaaaadd2c838 in leveldb::log::Reader::ReadPhysicalRecord(leveldb::Slice*) src/./src/leveldb/db/log_reader.cc:246:29
      #3 0xaaaaadd2ba9c in leveldb::log::Reader::ReadRecord(leveldb::Slice*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) src/./src/leveldb/db/log_reader.cc:72:38
      #4 0xaaaaadd41710 in leveldb::VersionSet::Recover(bool*) src/./src/leveldb/db/version_set.cc:910:19
      #5 0xaaaaadcf9fec in leveldb::DBImpl::Recover(leveldb::VersionEdit*, bool*) src/./src/leveldb/db/db_impl.cc:320:18
      #6 0xaaaaadd12068 in leveldb::DB::Open(leveldb::Options const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, leveldb::DB**) src/./src/leveldb/db/db_impl.cc:1487:20
      #7 0xaaaaad314e80 in CDBWrapper::CDBWrapper(DBParams const&) src/./src/dbwrapper.cpp:156:30
      #8 0xaaaaace94880 in CBlockTreeDB::CBlockTreeDB(DBParams const&) src/./txdb.h:89:23
      #9 0xaaaaace94880 in std::_MakeUniq<CBlockTreeDB>::__single_object std::make_unique<CBlockTreeDB, DBParams>(DBParams&&) /usr/bin/../lib/gcc/aarch64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:962:34
      #10 0xaaaaace94880 in ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<char const*, std::allocator<char const*> > const&) src/./src/test/util/setup_common.cpp:188:51
      #11 0xaaaaace95da0 in TestingSetup::TestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<char const*, std::allocator<char const*> > const&, bool, bool) src/./src/test/util/setup_common.cpp:243:7
      #12 0xaaaaace96730 in TestChain100Setup::TestChain100Setup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<char const*, std::allocator<char const*> > const&, bool, bool) src/./src/test/util/setup_common.cpp:274:7
      #13 0xaaaaac1ddbc8 in blockfilter_index_tests::BuildChainTestingSetup::BuildChainTestingSetup() src/./src/test/blockfilter_index_tests.cpp:26:8
      #14 0xaaaaac1ddbc8 in blockfilter_index_tests::blockfilter_index_initial_sync::blockfilter_index_initial_sync() src/./src/test/blockfilter_index_tests.cpp:112:1
      #15 0xaaaaac1ddbc8 in blockfilter_index_tests::blockfilter_index_initial_sync_invoker() src/./src/test/blockfilter_index_tests.cpp:112:1
      #16 0xaaaaabf08f7c in boost::function0<void>::operator()() const /usr/include/boost/function/function_template.hpp:763:14
      #17 0xaaaaabf95468 in boost::detail::forward::operator()() /usr/include/boost/test/impl/execution_monitor.ipp:1388:32
      #18 0xaaaaabf95468 in boost::detail::function::function_obj_invoker0<boost::detail::forward, int>::invoke(boost::detail::function::function_buffer&) /usr/include/boost/function/function_template.hpp:137:18
      #19 0xaaaaabf8e12c in boost::function0<int>::operator()() const /usr/include/boost/function/function_template.hpp:763:14
      #20 0xaaaaabe7be14 in boost::execution_monitor::catch_signals(boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:903:16
      #21 0xaaaaabe7c1c0 in boost::execution_monitor::execute(boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:1301:16
      #22 0xaaaaabe6f47c in boost::execution_monitor::vexecute(boost::function<void ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:1397:5
      #23 0xaaaaabe75124 in boost::unit_test::unit_test_monitor_t::execute_and_translate(boost::function<void ()> const&, unsigned long) /usr/include/boost/test/impl/unit_test_monitor.ipp:49:9
      #24 0xaaaaabed19fc in boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:815:44
      #25 0xaaaaabed0f6c in boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:784:58
      #26 0xaaaaabed0f6c in boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:784:58
      #27 0xaaaaabe73878 in boost::unit_test::framework::run(unsigned long, bool) /usr/include/boost/test/impl/framework.ipp:1721:29
      #28 0xaaaaabe9d244 in boost::unit_test::unit_test_main(boost::unit_test::test_suite* (*)(int, char**), int, char**) /usr/include/boost/test/impl/unit_test_main.ipp:250:9
      #29 0xffff8f0773f8  (/lib/aarch64-linux-gnu/libc.so.6+0x273f8) (BuildId: f37f3aa07c797e333fd106472898d361f71798f5)
      #30 0xffff8f0774c8 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x274c8) (BuildId: f37f3aa07c797e333fd106472898d361f71798f5)
      #31 0xaaaaabda55ac in _start (/home/fedora/ci_scratch/ci/scratch/build/bitcoin-aarch64-unknown-linux-gnu/src/test/test_bitcoin+0x10e55ac) (BuildId: b7909adaefd9db6cd6a7c4d3d40207cf6bdaf4b3)

  SUMMARY: UndefinedBehaviorSanitizer: misaligned-pointer-use crc32c/src/crc32c_arm64.cc:101:26 in
  ```

ACKs for top commit:
  dergoegge:
    utACK f952e67
  MarcoFalke:
    lgtm ACK f952e67

Tree-SHA512: 9dee2abf73d3f23bb9979bfb453b48e39f0b7a5f58d43824ecf053a53e9800ed413b915382b274d1a84baf2999683e3b485463e377e0455b3f0ead65ed1d1916
hebasto pushed a commit that referenced this pull request Jun 23, 2023
682274a ci: install llvm-symbolizer in MSAN jobs (fanquake)
96527cd ci: use LLVM 16.0.6 in MSAN jobs (fanquake)

Pull request description:

  Fixes: bitcoin#27737 (comment).

  Tested (locally) with bitcoin#27495 that it produces a symbolized backtrace:
  ```bash
  2023-06-20T17:5Uninitialized bytes in __interceptor_strlen at offset 113 inside [0x719000006908, 114)
  ==35429==WARNING: MemorySanitizer: use-of-uninitialized-value
      #0 0x56060fae8c4b in sqlite3Strlen30 /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:32670:28
      #1 0x56060fb0fcf4 in sqlite3PagerOpen /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:57953:17
      #2 0x56060fb0f48b in sqlite3BtreeOpen /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:68679:10
      #3 0x56060fb01384 in openDatabase /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:171911:8
      #4 0x56060fb016ca in sqlite3_open_v2 /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:172034:10
      #5 0x56060e8a94db in wallet::SQLiteDatabase::Open() src/wallet/sqlite.cpp:250:19
      #6 0x56060e8a30fd in wallet::SQLiteDatabase::SQLiteDatabase(fs::path const&, fs::path const&, wallet::DatabaseOptions const&, bool) src/wallet/sqlite.cpp:133:9
      #7 0x56060e8b78f5 in std::__1::__unique_if<wallet::SQLiteDatabase>::__unique_single std::__1::make_unique[abi:v160006]<wallet::SQLiteDatabase, std::__1::__fs::filesystem::path, fs::path&, wallet::DatabaseOptions const&>(std::__1::__fs::filesystem::path&&, fs::path&, wallet::DatabaseOptions const&) /home/ubuntu/ci_scratch/ci/scratch/msan/cxx_build/include/c++/v1/__memory/unique_ptr.h:686:30
      #8 0x56060e8b5240 in wallet::MakeSQLiteDatabase(fs::path const&, wallet::DatabaseOptions const&, wallet::DatabaseStatus&, bilingual_str&) src/wallet/sqlite.cpp:641:19
      #9 0x56060e83560b in wallet::MakeDatabase(fs::path const&, wallet::DatabaseOptions const&, wallet::DatabaseStatus&, bilingual_str&) src/wallet/walletdb.cpp:1261:16
      #10 0x56060e7546e9 in wallet::MakeWalletDatabase(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, wallet::DatabaseOptions const&, wallet::DatabaseStatus&, bilingual_str&) src/wallet/wallet.cpp:2905:12
      #11 0x56060e4bc03f in wallet::TestLoadWallet(wallet::WalletContext&) src/wallet/test/util.cpp:68:21
      #12 0x56060e349ad4 in wallet::wallet_tests::ZapSelectTx::test_method() src/wallet/test/wallet_tests.cpp:897:19
      #13 0x56060e348598 in wallet::wallet_tests::ZapSelectTx_invoker() src/wallet/test/wallet_tests.cpp:891:1
      #14 0x56060cfec325 in boost::detail::function::void_function_invoker0<void (*)(), void>::invoke(boost::detail::function::function_buffer&) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:117:11
      #15 0x56060ced3a7e in boost::function0<void>::operator()() const /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:763:14
      #16 0x56060ced3a7e in boost::detail::forward::operator()() /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:1388:32
      #17 0x56060ced3a7e in boost::detail::function::function_obj_invoker0<boost::detail::forward, int>::invoke(boost::detail::function::function_buffer&) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:137:18
      #18 0x56060cda71c2 in boost::function0<int>::operator()() const /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:763:14
      #19 0x56060cda71c2 in int boost::detail::do_invoke<boost::shared_ptr<boost::detail::translator_holder_base>, boost::function<int ()>>(boost::shared_ptr<boost::detail::translator_holder_base> const&, boost::function<int ()> const&) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:301:30
      #20 0x56060cda71c2 in boost::execution_monitor::catch_signals(boost::function<int ()> const&) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:903:16
      #21 0x56060cda784a in boost::execution_monitor::execute(boost::function<int ()> const&) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:1301:16
      #22 0x56060cd9ec3a in boost::execution_monitor::vexecute(boost::function<void ()> const&) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:1397:5
      #23 0x56060cd9ec3a in boost::unit_test::unit_test_monitor_t::execute_and_translate(boost::function<void ()> const&, unsigned long) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/unit_test_monitor.ipp:49:9
      #24 0x56060ce1a07b in boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:815:44
      #25 0x56060ce1ad8b in boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:784:58
      #26 0x56060ce1ad8b in boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:784:58
      #27 0x56060cd9b8de in boost::unit_test::framework::run(unsigned long, bool) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/framework.ipp:1722:29
      #28 0x56060cdd4fac in boost::unit_test::unit_test_main(boost::unit_test::test_suite* (*)(int, char**), int, char**) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/unit_test_main.ipp:250:9
      #29 0x56060cdd6094 in main /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/unit_test_main.ipp:306:12
      #30 0x7f7379691d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 69389d485a9793dbe873f0ea2c93e02efaa9aa3d)
      #31 0x7f7379691e3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f) (BuildId: 69389d485a9793dbe873f0ea2c93e02efaa9aa3d)
      #32 0x56060cce2e24 in _start (/home/ubuntu/ci_scratch/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/test_bitcoin+0x188e24)

    Uninitialized value was created by a heap allocation
      #0 0x56060cd163f2 in malloc /ci_base_install/ci/scratch/msan/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:934:3
      #1 0x56060fc10069 in sqlite3MemMalloc /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:25163:7
      #2 0x56060fb063bc in mallocWithAlarm /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:28846:7
      #3 0x56060fae4eb9 in sqlite3Malloc /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:28876:5
      #4 0x56060faf9e19 in sqlite3DbMallocRaw /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:29176:7
      #5 0x56060fb0fc67 in sqlite3PagerOpen /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:57938:17
      #6 0x56060fb0f48b in sqlite3BtreeOpen /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:68679:10
      #7 0x56060fb01384 in openDatabase /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:171911:8
      #8 0x56060fb016ca in sqlite3_open_v2 /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:172034:10
      #9 0x56060e8a94db in wallet::SQLiteDatabase::Open() src/wallet/sqlite.cpp:250:19
      #10 0x56060e8a30fd in wallet::SQLiteDatabase::SQLiteDatabase(fs::path const&, fs::path const&, wallet::DatabaseOptions const&, bool) src/wallet/sqlite.cpp:133:9
      #11 0x56060e8b78f5 in std::__1::__unique_if<wallet::SQLiteDatabase>::__unique_single std::__1::make_unique[abi:v160006]<wallet::SQLiteDatabase, std::__1::__fs::filesystem::path, fs::path&, wallet::DatabaseOptions const&>(std::__1::__fs::filesystem::path&&, fs::path&, wallet::DatabaseOptions const&) /home/ubuntu/ci_scratch/ci/scratch/msan/cxx_build/include/c++/v1/__memory/unique_ptr.h:686:30
      #12 0x56060e8b5240 in wallet::MakeSQLiteDatabase(fs::path const&, wallet::DatabaseOptions const&, wallet::DatabaseStatus&, bilingual_str&) src/wallet/sqlite.cpp:641:19
      #13 0x56060e83560b in wallet::MakeDatabase(fs::path const&, wallet::DatabaseOptions const&, wallet::DatabaseStatus&, bilingual_str&) src/wallet/walletdb.cpp:1261:16
      #14 0x56060e7546e9 in wallet::MakeWalletDatabase(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, wallet::DatabaseOptions const&, wallet::DatabaseStatus&, bilingual_str&) src/wallet/wallet.cpp:2905:12
      #15 0x56060e4bc03f in wallet::TestLoadWallet(wallet::WalletContext&) src/wallet/test/util.cpp:68:21
      #16 0x56060e349ad4 in wallet::wallet_tests::ZapSelectTx::test_method() src/wallet/test/wallet_tests.cpp:897:19
      #17 0x56060e348598 in wallet::wallet_tests::ZapSelectTx_invoker() src/wallet/test/wallet_tests.cpp:891:1
      #18 0x56060cfec325 in boost::detail::function::void_function_invoker0<void (*)(), void>::invoke(boost::detail::function::function_buffer&) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:117:11
      #19 0x56060ced3a7e in boost::function0<void>::operator()() const /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:763:14
      #20 0x56060ced3a7e in boost::detail::forward::operator()() /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/test/impl/execution_monitor.ipp:1388:32
      #21 0x56060ced3a7e in boost::detail::function::function_obj_invoker0<boost::detail::forward, int>::invoke(boost::detail::function::function_buffer&) /home/ubuntu/ci_scratch/depends/x86_64-pc-linux-gnu/include/boost/function/function_template.hpp:137:18

  SUMMARY: MemorySanitizer: use-of-uninitialized-value /home/ubuntu/ci_scratch/depends/work/build/x86_64-pc-linux-gnu/sqlite/3380500-f816a3e2d52/sqlite3.c:32670:28 in sqlite3Strlen30
  ```

  as opposed to unsymbolized: https://cirrus-ci.com/task/6005512018329600?logs=ci#L3245.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 682274a

Tree-SHA512: 8f3e7636761c956537a472989bf07529f5afbd988c5e7e1f07ece8b2599608fa4fe9e1efdc6e302cf0f7f44dec3cf9a3c1e68b758af81a8a8b476a43d3220807
hebasto added a commit that referenced this pull request Jul 7, 2023
43123cf FIXUP: Same as PR27458 (Hennadii Stepanov)
2d8930e FIXUP: Same as PR27656 (Hennadii Stepanov)
a112470 cmake: Include CTest (Hennadii Stepanov)
cb19814 cmake: Build `test_bitcoin` executable (Hennadii Stepanov)
751453f cmake: Build `bench_bitcoin` executable (Hennadii Stepanov)
a2c3493 cmake: Add test config and runners (Hennadii Stepanov)
cb7dc94 test: Explicitly specify directory where to search tests for (Hennadii Stepanov)
2fd303f test: Make `util/test_runner.py` honor `BITCOINUTIL` and `BITCOINTX` (Hennadii Stepanov)
2e3721e cmake: Add wallet functionality (Hennadii Stepanov)
f944ccd cmake: Build `bitcoin-util` executable (Hennadii Stepanov)
d1c319d cmake: Build `bitcoin-tx` executable (Hennadii Stepanov)
1934755 cmake: Build `bitcoin-cli` executable (Hennadii Stepanov)
5fc2cee [FIXUP] cmake: Add workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/20652 (Hennadii Stepanov)
b2bea9f [FIXUP] cmake: Consider `ASM` option when checking for `HAVE_64BIT_ASM` (Hennadii Stepanov)

Pull request description:

  The parent PR: bitcoin#25797.
  The previous PRs in the staging branch: #5, #6, #7, #10, #13.

  ---

  What is NEW:
  - `bitcoin-cli`
  - `bitcoin-tx`
  - `bitcoin-util`
  - wallet functionality and `bitcoin-wallet`
  - `bench_bitcoin`
  - `test_bitcoin`

  EXAMPLES:
  ```
  cmake -S . -B build
  cd build
  cmake --build . -j $(nproc)
  ctest -j $(nproc)
  ./test/functional/test_runner.py -j $(nproc)
  ```

  Using a multi-configuration generator (CMake 3.17+ is required):
  ```
  cmake -S . -B build -G "Ninja Multi-Config"
  cd build
  cmake --build . -j $(nproc)
  ctest -j $(nproc) -C Debug
  ```
  ---

  What to test:
  - old CMake versions, for example v3.13
  - multi-config generators, for example `-G "Ninja Multi-Config"`

  ---

  What to consider additionally:
  - is it worth to pull the "[test: Make util/test_runner.py honor BITCOINUTIL and BITCOINTX](268aca3)" commit to the main repo now?

  FWIW, we use the same approach for functional tests providing the `BITCOIND` environment variable when needed.

ACKs for top commit:
  TheCharlatan:
    ACK 43123cf

Tree-SHA512: a04cfca266bcde780528c915cb01f69189f36a0e1beb521fe75e4816ca4f9ab9440646529bbf2cbdfe76275debc5107ee2433e1027405094d3e8a74ec0d1d077
hebasto added a commit that referenced this pull request Jul 20, 2023
a933ddf [FIXUP] Better document a workaround (Hennadii Stepanov)
769633e [FIXUP] for "cmake: Add wallet functionality" (Hennadii Stepanov)
31e4e62 [FIXUP] for "cmake: Build `test_bitcoin` executable" (Hennadii Stepanov)
f2dbb17 [FIXUP] for "cmake: Build `test_bitcoin` executable" (Hennadii Stepanov)
91d7327 [FIXUP] Boost (Hennadii Stepanov)

Pull request description:

  The parent PR: bitcoin#25797.
  The previous PRs in the staging branch: #5, #6, #7, #10, #13, #15.

  This PR consists of fixups only to make reviewing easier :)

ACKs for top commit:
  theuni:
    ACK a933ddf

Tree-SHA512: 270869a3bf9b9f2d56b75d169f25032385fa2d1297951a23c0d1900d9668a40b153c7a5d9b51fa87596eec681107c40da8e55f405d28a7ecd2ec0f72f3550bbf
hebasto added a commit that referenced this pull request Jul 20, 2023
ac7bc5b [FIXUP] Rename CCACHE_EXECUTABLE --> CCACHE_COMMAND for consistency (Hennadii Stepanov)
0476509 [FIXUP] Learn to work with recent ccache in MSVC builds (Hennadii Stepanov)
2fd67c7 [FIXUP] Do not disable `TrackFileAccess` in MSVC builds (Hennadii Stepanov)
a53ae12 [FIXUP] Use Multi-ToolTask in MSVC builds by default (Hennadii Stepanov)

Pull request description:

  The parent PR: bitcoin#25797.
  The previous PRs in the staging branch: #5, #6, #7, #10, #13, #15, #17, #18.

  This PR consists of fixups related to using [Ccache](https://ccache.dev/) in MSVC builds.

Top commit has no ACKs.

Tree-SHA512: dc01202b054aaeb5b46607bc93126bee0df523df3b4f2df54b566b2e2d6306d784a723fd4a999d0d84fdf31e926a72304790f94b9d57034db0c112ee9f52070e
hebasto added a commit that referenced this pull request Sep 13, 2023
a65da0d cmake: Redefine configuration flags (Hennadii Stepanov)
1a1dda5 [FIXUP] Evaluate flags set in depends _after_ config-specific flags (Hennadii Stepanov)
482e844 cmake: Warn about not encapsulated build properties (Hennadii Stepanov)
3736470 cmake: Add platform-specific flags (Hennadii Stepanov)
e0621e9 cmake: Add `TryAppendLinkerFlag` module (Hennadii Stepanov)
ae430cf cmake: Add `TryAppendCXXFlags` module (Hennadii Stepanov)
7903bd5 [FIXUP] Encapsulate common build flags into `core` interface library (Hennadii Stepanov)

Pull request description:

  The parent PR: bitcoin#25797.
  The previous PRs in the staging branch: #5, #6, #7, #10, #13, #15, #17, #19.

  ---

  What is NEW:
  - functions for checking compiler and linker flags
  - managing flags for different build types (configurations)

  EXAMPLES of configuration output on Ubuntu 22.04:

  -  for a single-config generator:
  ```
  $ cmake .. -G "Unix Makefiles"
  ...
  Cross compiling ....................... FALSE
  Preprocessor defined macros ...........
  C compiler ............................ /usr/bin/cc
  CFLAGS ................................
  C++ compiler .......................... /usr/bin/c++
  CXXFLAGS ..............................
  Common compile options ................
  Common link options ...................
  Linker flags for executables ..........
  Linker flags for shared libraries .....
  Build type (configuration):
   - CMAKE_BUILD_TYPE ................... RelWithDebInfo
   - Preprocessor defined macros ........
   - CFLAGS ............................. -O2 -g
   - CXXFLAGS ........................... -O2 -g
   - LDFLAGS for executables ............
   - LDFLAGS for shared libraries .......
  Use assembly routines ................. ON
  Use ccache for compiling .............. ON
  ...
  ```

  - for a multi-config generator:
  ```
  $ cmake .. -G "Ninja Multi-Config"
  ...
  Cross compiling ....................... FALSE
  Preprocessor defined macros ...........
  C compiler ............................ /usr/bin/cc
  CFLAGS ................................
  C++ compiler .......................... /usr/bin/c++
  CXXFLAGS ..............................
  Common compile options ................
  Common link options ...................
  Linker flags for executables ..........
  Linker flags for shared libraries .....
  Available build types (configurations)  RelWithDebInfo Debug Release
  'RelWithDebInfo' build type (configuration):
   - Preprocessor defined macros ........
   - CFLAGS ............................. -O2 -g
   - CXXFLAGS ........................... -O2 -g
   - LDFLAGS for executables ............
   - LDFLAGS for shared libraries .......
  'Debug' build type (configuration):
   - Preprocessor defined macros ........ DEBUG DEBUG_LOCKORDER DEBUG_LOCKCONTENTION RPC_DOC_CHECK ABORT_ON_FAILED_ASSUME
   - CFLAGS ............................. -O0 -g3
   - CXXFLAGS ........................... -O0 -g3 -ftrapv
   - LDFLAGS for executables ............
   - LDFLAGS for shared libraries .......
  'Release' build type (configuration):
   - Preprocessor defined macros ........
   - CFLAGS ............................. -O2
   - CXXFLAGS ........................... -O2
   - LDFLAGS for executables ............
   - LDFLAGS for shared libraries .......
  Use assembly routines ................. ON
  Use ccache for compiling .............. ON
  ...
  ```

  - cross-compiling for Windows:
  ```
  $ make -C depends HOST=x86_64-w64-mingw32 DEBUG=1 NO_QT=1
  $ cmake -B build --toolchain depends/x86_64-w64-mingw32/share/toolchain.cmake -DCMAKE_BUILD_TYPE=Debug
  ...
  Cross compiling ....................... TRUE, for Windows, x86_64
  Preprocessor defined macros ........... _WIN32_WINNT=0x0601 _WIN32_IE=0x0501 WIN32_LEAN_AND_MEAN NOMINMAX WIN32 _WINDOWS _MT _GLIBCXX_DEBUG _GLIBCXX_DEBUG_PEDANTIC
  C compiler ............................ /usr/bin/x86_64-w64-mingw32-gcc
  CFLAGS ................................ -pipe -std=c11 -O1
  C++ compiler .......................... /usr/bin/x86_64-w64-mingw32-g++-posix
  CXXFLAGS .............................. -pipe -std=c++17 -O1
  Common compile options ................
  Common link options ................... -Wl,--major-subsystem-version,6 -Wl,--minor-subsystem-version,1
  Linker flags for executables .......... -static
  Linker flags for shared libraries .....
  Build type (configuration):
   - CMAKE_BUILD_TYPE ................... Debug
   - Preprocessor defined macros ........ DEBUG DEBUG_LOCKORDER DEBUG_LOCKCONTENTION RPC_DOC_CHECK ABORT_ON_FAILED_ASSUME
   - CFLAGS ............................. -O0 -g3
   - CXXFLAGS ........................... -O0 -g3 -ftrapv
   - LDFLAGS for executables ............
   - LDFLAGS for shared libraries .......
  Use assembly routines ................. ON
  Use ccache for compiling .............. ON
  ...
  ```

  **A cross-project note.** The `ProcessConfigurations.cmake` is based on the same module that was suggested in bitcoin-core/secp256k1#1291. So, cross-reviewing is welcome :)

ACKs for top commit:
  theuni:
    ACK a65da0d to keep this moving. This has been sitting for too long :(

Tree-SHA512: 57c5e91ddf9675c6a2b56c0cb70fd3f045af8076bee74c49390de38b8d514e130d2086fde6d83d2d1278b437d0a10cc721f0aa44934698110aeadb3a1aef9e64
hebasto pushed a commit that referenced this pull request Nov 29, 2023
…BlockTx suppression

fa9dc92 test: Add missing CBlockPolicyEstimator::processBlockTx suppression (MarcoFalke)

Pull request description:

  Fixes bitcoin#28865 (comment)

  ```
  # FUZZ=policy_estimator UBSAN_OPTIONS="suppressions=/root/fuzz_dir/scratch/fuzz_gen/code/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" ./src/test/fuzz/fuzz /tmp/crash-154b42214e70781a9c1ad72d3f2693913dcf8c06

  ...

  policy/fees.cpp:632:27: runtime error: implicit conversion from type 'unsigned int' of value 4294574080 (32-bit, unsigned) to type 'int' changed the value to -393216 (32-bit, signed)
      #0 0x55cbbe10daee in CBlockPolicyEstimator::processBlockTx(unsigned int, CTxMemPoolEntry const*) src/policy/fees.cpp:632:27
      #1 0x55cbbe10e361 in CBlockPolicyEstimator::processBlock(unsigned int, std::vector<CTxMemPoolEntry const*, std::allocator<CTxMemPoolEntry const*>>&) src/policy/fees.cpp:680:13
      #2 0x55cbbd84af48 in policy_estimator_fuzz_target(Span<unsigned char const>)::$_1::operator()() const src/test/fuzz/policy_estimator.cpp:69:40
      #3 0x55cbbd84af48 in unsigned long CallOneOf<policy_estimator_fuzz_target(Span<unsigned char const>)::$_0, policy_estimator_fuzz_target(Span<unsigned char const>)::$_1, policy_estimator_fuzz_target(Span<unsigned char const>)::$_2, policy_estimator_fuzz_target(Span<unsigned char const>)::$_3>(FuzzedDataProvider&, policy_estimator_fuzz_target(Span<unsigned char const>)::$_0, policy_estimator_fuzz_target(Span<unsigned char const>)::$_1, policy_estimator_fuzz_target(Span<unsigned char const>)::$_2, policy_estimator_fuzz_target(Span<unsigned char const>)::$_3) src/./test/fuzz/util.h:43:27
      #4 0x55cbbd84af48 in policy_estimator_fuzz_target(Span<unsigned char const>) src/test/fuzz/policy_estimator.cpp:38:9
      #5 0x55cbbda1cc18 in std::function<void (Span<unsigned char const>)>::operator()(Span<unsigned char const>) const /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:591:9
      #6 0x55cbbda1cc18 in LLVMFuzzerTestOneInput src/test/fuzz/fuzz.cpp:178:5
      #7 0x55cbbd26a944 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/root/fuzz_dir/scratch/fuzz_gen/code/src/test/fuzz/fuzz+0x190e944) (BuildId: ffb89e0b86c093ca3bdeae6f85537737a4e3b42d)
      #8 0x55cbbd253916 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/root/fuzz_dir/scratch/fuzz_gen/code/src/test/fuzz/fuzz+0x18f7916) (BuildId: ffb89e0b86c093ca3bdeae6f85537737a4e3b42d)
      #9 0x55cbbd25945a in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/root/fuzz_dir/scratch/fuzz_gen/code/src/test/fuzz/fuzz+0x18fd45a) (BuildId: ffb89e0b86c093ca3bdeae6f85537737a4e3b42d)
      #10 0x55cbbd284026 in main (/root/fuzz_dir/scratch/fuzz_gen/code/src/test/fuzz/fuzz+0x1928026) (BuildId: ffb89e0b86c093ca3bdeae6f85537737a4e3b42d)
      #11 0x7fe4aa8280cf  (/lib/x86_64-linux-gnu/libc.so.6+0x280cf) (BuildId: 96ab1a8f3b2c9a2ed37c7388615e6a726d037e89)
      #12 0x7fe4aa828188 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x28188) (BuildId: 96ab1a8f3b2c9a2ed37c7388615e6a726d037e89)
      #13 0x55cbbd24e494 in _start (/root/fuzz_dir/scratch/fuzz_gen/code/src/test/fuzz/fuzz+0x18f2494) (BuildId: ffb89e0b86c093ca3bdeae6f85537737a4e3b42d)

  SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change policy/fees.cpp:632:27 in
  ```

  ```
  # base64 /tmp/crash-154b42214e70781a9c1ad72d3f2693913dcf8c06
  AQEAAAAAADkFlVwAAQEAAAAAADkFlZVcACTDSSsP3746IAZrH48khwMAAQEB/QEALQAACwAAAAAA
  FgAAAAAAAQAABgAAAAAAAAAAAAAAAAAAACcQAAAAAAAAAAAAAAAAAAAAAAD6AAAAOQWVXAABAQAA
  AAAAOQWVlVwAIMNJKw/fvjogBmsfjySHAwABAQH9AQAtAAALAAAAAAAAAAABAAAGAAAAAAAAAAAA
  AAAAAAAAJxAAAAAAAAAAAAAAAAAAAAAAAPr/AAAAAAAAAAAAAAQAAAAA/wAAAAAAAAAAAAAEAAAA
  AAEBAeAIAVwBXAAA/jbSBvwBKABSKBwBYgEB2wAEkvXInHYAAAAAAAAAvgAAAAAA/9//6v8e/xIk
  MgAlAiUAOw==

ACKs for top commit:
  fanquake:
    ACK fa9dc92
  dergoegge:
    utACK fa9dc92

Tree-SHA512: 3898c17c928ecc2bcc8c7086359e9ae00da2197b4d8e10c7bf6d12415326c9bca3ef6e1d8d3b83172ccfa604ce7e7371415262ba705225f9ea4da8b1a7eb0306
hebasto pushed a commit that referenced this pull request Nov 30, 2023
…tifications fuzz target

fab164f fuzz: Avoid signed-integer-overflow in wallet_notifications fuzz target (MarcoFalke)

Pull request description:

  Should avoid

  ```
  policy/feerate.cpp:29:63: runtime error: signed integer overflow: 77600710321911316 * 149 cannot be represented in type 'int64_t' (aka 'long')
      #0 0x563a1775ed66 in CFeeRate::GetFee(unsigned int) const src/policy/feerate.cpp:29:63
      #1 0x563a15913a69 in wallet::COutput::COutput(COutPoint const&, CTxOut const&, int, int, bool, bool, bool, long, bool, std::optional<CFeeRate>) src/./wallet/coinselection.h:91:57
      #2 0x563a16fa6a6d in wallet::FetchSelectedInputs(wallet::CWallet const&, wallet::CCoinControl const&, wallet::CoinSelectionParams const&) src/wallet/spend.cpp:297:17
      #3 0x563a16fc4512 in wallet::CreateTransactionInternal(wallet::CWallet&, std::vector<wallet::CRecipient, std::allocator<wallet::CRecipient>> const&, int, wallet::CCoinControl const&, bool) src/wallet/spend.cpp:1105:33
      #4 0x563a16fbec74 in wallet::CreateTransaction(wallet::CWallet&, std::vector<wallet::CRecipient, std::allocator<wallet::CRecipient>> const&, int, wallet::CCoinControl const&, bool) src/wallet/spend.cpp:1291:16
      #5 0x563a16fcf6df in wallet::FundTransaction(wallet::CWallet&, CMutableTransaction&, long&, int&, bilingual_str&, bool, std::set<int, std::less<int>, std::allocator<int>> const&, wallet::CCoinControl) src/wallet/spend.cpp:1361:16
      #6 0x563a1597b7b9 in wallet::(anonymous namespace)::FuzzedWallet::FundTx(FuzzedDataProvider&, CMutableTransaction) src/wallet/test/fuzz/notifications.cpp:162:15
      #7 0x563a15958240 in wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_0::operator()() const src/wallet/test/fuzz/notifications.cpp:228:23
      #8 0x563a15958240 in unsigned long CallOneOf<wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_0, wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_1>(FuzzedDataProvider&, wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_0, wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>)::$_1) src/./test/fuzz/util.h:43:27
      #9 0x563a15958240 in wallet::(anonymous namespace)::wallet_notifications_fuzz_target(Span<unsigned char const>) src/wallet/test/fuzz/notifications.cpp:196:9
      #10 0x563a15fdef0c in std::function<void (Span<unsigned char const>)>::operator()(Span<unsigned char const>) const /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:591:9
      #11 0x563a15fdef0c in LLVMFuzzerTestOneInput src/test/fuzz/fuzz.cpp:178:5
      #12 0x563a158032a4 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x19822a4) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #13 0x563a15802999 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1981999) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #14 0x563a15804586 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1983586) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #15 0x563a15804aa7 in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1983aa7) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #16 0x563a157f21fb in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x19711fb) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #17 0x563a1581c766 in main (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x199b766) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)
      #18 0x7f499e17b0cf  (/lib/x86_64-linux-gnu/libc.so.6+0x280cf) (BuildId: 96ab1a8f3b2c9a2ed37c7388615e6a726d037e89)
      #19 0x7f499e17b188 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x28188) (BuildId: 96ab1a8f3b2c9a2ed37c7388615e6a726d037e89)
      #20 0x563a157e70c4 in _start (/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x19660c4) (BuildId: 8acb42ad599d7f6d25b6f93e18fd564d80df7c06)

  SUMMARY: UndefinedBehaviorSanitizer: signed-integer-overflow policy/feerate.cpp:29:63 in
  MS: 0 ; base unit: 0000000000000000000000000000000000000000
  0x3f,0x0,0x2f,0x5f,0x5f,0x5f,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0xff,0xff,0xff,0xff,0xff,0x53,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x13,0x5e,0x5f,0x5f,0x8,0x25,0x0,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x8,0x25,0xca,0x7f,0x5f,0x5f,0x5f,0x13,0x13,0x5f,0x5f,0x5f,0x2,0xdb,0xca,0x0,0x0,0xe7,0xe6,0x66,0x65,0x0,0x0,0x0,0x0,0x44,0x3f,0xa,0xa,0xff,0xff,0xff,0xff,0xff,0x61,0x76,0x6f,0x69,0x0,0xb5,0x15,
  ?\000/___}}}}}}}}}}}}}}}}}}}}\377\377\377\377\377S\377\377\377\377\377\000\000\000\000\000\000\023^__\010%\000______\010%\312\177___\023\023___\002\333\312\000\000\347\346fe\000\000\000\000D?\012\012\377\377\377\377\377avoi\000\265\025
  artifact_prefix='./'; Test unit written to ./crash-4d3bac8a64d4e58b2f0943e6d28e6e1f16328d7d
  Base64: PwAvX19ffX19fX19fX19fX19fX19fX19fX3//////1P//////wAAAAAAABNeX18IJQBfX19fX18IJcp/X19fExNfX18C28oAAOfmZmUAAAAARD8KCv//////YXZvaQC1FQ==

ACKs for top commit:
  dergoegge:
    ACK fab164f
  brunoerg:
    ACK fab164f

Tree-SHA512: f416828f4394aa7303ee437f141e9bbd23c0e0f1b830e4ef3932338858249ba68a811b9837c5b7ad8c6ab871b6354996434183597c1a910a8d8e8d829693e4b2
hebasto pushed a commit that referenced this pull request Apr 8, 2024
…allet_importdescriptors

49c0b8b test: Bump timeouts in feature_index_prune and wallet_importdescriptors (Christopher Bergqvist)

Pull request description:

  Timeout issues where encountered when running functional tests with `--jobs=16 --extended`.

  Note that running `--extended` without `--jobs=16` does not trigger the issues.

  Tested under NixOS on a Xeon CPU with 16 logical cores.

  (A few tests are skipped locally as I haven't enabled BPF and a few other things).

  ## Measurements

  Line in `feature_index_prune.py` took 101.6s, 96.6s, 103.0s across 3 runs on my machine.
  Default limit is 60, suggested to increase limit to 150 seconds.

  Line in the `wallet_importdescriptors.py --descriptors` took 5.4s, 5.7s, 6.0s across 3 runs.
  Suggested to increase from 5 to 10 seconds.

  ## Logs

  Output slightly modified by separate change that lets code run past given timeouts and the provides more information - "Took 101.6 seconds to complete, 69.4% over the given limit.".

  <details>
  <summary>
  Click to expand.
  </summary>

  ### feature_index_prune.py
  ```
  52/305 - feature_index_prune.py failed, Duration: 250 s

  stdout:
  2024-04-01T22:25:24.010000Z TestFramework (INFO): PRNG seed is: 990421162716295219
  2024-04-01T22:25:24.014000Z TestFramework (INFO): Initializing test directory /mnt/tmp/test_runner_₿_🏃_20240402_002516/feature_index_prune_302
  2024-04-01T22:25:24.913000Z TestFramework (INFO): check if we can access blockfilters and coinstats when pruning is enabled but no blocks are actually pruned
  2024-04-01T22:26:48.417000Z TestFramework (INFO): prune some blocks
  2024-04-01T22:26:48.460000Z TestFramework (INFO): check if we can access the tips blockfilter and coinstats when we have pruned some blocks
  2024-04-01T22:26:48.483000Z TestFramework (INFO): check if we can access the blockfilter and coinstats of a pruned block
  2024-04-01T22:26:59.175000Z TestFramework (INFO): make sure trying to access the indices throws errors
  2024-04-01T22:27:50.422000Z TestFramework (INFO): prune exactly up to the indices best blocks while the indices are disabled
  2024-04-01T22:27:52.596000Z TestFramework (INFO): make sure that we can continue with the partially synced indices after having pruned up to the index height
  2024-04-01T22:29:34.242000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: '''
          self.wait_until(lambda: self.nodes[1].getindexinfo() == expected_stats)#, timeout=150)
  '''
  2024-04-01T22:29:34.244000Z TestFramework (ERROR): Assertion failed
  Traceback (most recent call last):
    File "/home/chris/Documents/Code/bitcoin-core/test/functional/test_framework/test_framework.py", line 132, in main
      self.run_test()
    File "/home/chris/Documents/Code/bitcoin-core/test/functional/feature_index_prune.py", line 117, in run_test
      self.sync_index(height=1500)
    File "/home/chris/Documents/Code/bitcoin-core/test/functional/feature_index_prune.py", line 34, in sync_index
      self.wait_until(lambda: self.nodes[1].getindexinfo() == expected_stats)#, timeout=150)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/chris/Documents/Code/bitcoin-core/test/functional/test_framework/test_framework.py", line 780, in wait_until
      return wait_until_helper_internal(test_function, timeout=timeout, timeout_factor=self.options.timeout_factor)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/chris/Documents/Code/bitcoin-core/test/functional/test_framework/util.py", line 305, in wait_until_helper_internal
      raise AssertionError(m)
  AssertionError: Predicate '''
          self.wait_until(lambda: self.nodes[1].getindexinfo() == expected_stats)#, timeout=150)
  ''' not true after 60 seconds. Took 101.6 seconds to complete, 69.4% over the given limit.
  2024-04-01T22:29:34.298000Z TestFramework (INFO): Stopping nodes
  2024-04-01T22:29:34.511000Z TestFramework (WARNING): Not cleaning up dir /mnt/tmp/test_runner_₿_🏃_20240402_002516/feature_index_prune_302
  2024-04-01T22:29:34.511000Z TestFramework (ERROR): Test failed. Test logging available at /mnt/tmp/test_runner_₿_🏃_20240402_002516/feature_index_prune_302/test_framework.log
  2024-04-01T22:29:34.511000Z TestFramework (ERROR):
  2024-04-01T22:29:34.512000Z TestFramework (ERROR): Hint: Call /home/chris/Documents/Code/bitcoin-core/test/functional/combine_logs.py '/mnt/tmp/test_runner_₿_🏃_20240402_002516/feature_index_prune_302' to consolidate all logs
  2024-04-01T22:29:34.512000Z TestFramework (ERROR):
  2024-04-01T22:29:34.512000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
  2024-04-01T22:29:34.512000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
  2024-04-01T22:29:34.512000Z TestFramework (ERROR):

  stderr:

  53/305 - p2p_blockfilters.py passed, Duration: 130 s
  ```

  ### wallet_importdescriptors.py --descriptors

  ```
  297/305 - wallet_importdescriptors.py --descriptors failed, Duration: 76 s

  stdout:
  2024-04-01T22:48:27.663000Z TestFramework (INFO): PRNG seed is: 8528678505617325332
  2024-04-01T22:48:27.664000Z TestFramework (INFO): Initializing test directory /mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98
  2024-04-01T22:48:28.021000Z TestFramework (INFO): Setting up wallets
  2024-04-01T22:48:28.100000Z TestFramework (INFO): Mining coins
  2024-04-01T22:48:29.714000Z TestFramework (INFO): Import should fail if a descriptor is not provided
  2024-04-01T22:48:29.725000Z TestFramework (INFO): Should import a p2pkh descriptor
  2024-04-01T22:48:29.740000Z TestFramework (INFO): Test can import same descriptor with public key twice
  2024-04-01T22:48:29.760000Z TestFramework (INFO): Test can update descriptor label
  2024-04-01T22:48:29.785000Z TestFramework (INFO): Internal addresses cannot have labels
  2024-04-01T22:48:29.788000Z TestFramework (INFO): Internal addresses should be detected as such
  2024-04-01T22:48:29.854000Z TestFramework (INFO): Should not import a p2sh-p2wpkh descriptor without checksum
  2024-04-01T22:48:29.855000Z TestFramework (INFO): Should not import a p2sh-p2wpkh descriptor that has range specified
  2024-04-01T22:48:29.858000Z TestFramework (INFO): Should not import a p2sh-p2wpkh descriptor and have it set to active
  2024-04-01T22:48:29.860000Z TestFramework (INFO): Should import a (non-active) p2sh-p2wpkh descriptor
  2024-04-01T22:48:29.984000Z TestFramework (INFO): Should import a 1-of-2 bare multisig from descriptor
  2024-04-01T22:48:30.002000Z TestFramework (INFO): Should not treat individual keys from the imported bare multisig as watchonly
  2024-04-01T22:48:30.005000Z TestFramework (INFO): Ranged descriptors cannot have labels
  2024-04-01T22:48:30.014000Z TestFramework (INFO): Private keys required for private keys enabled wallet
  2024-04-01T22:48:30.027000Z TestFramework (INFO): Ranged descriptor import should warn without a specified range
  2024-04-01T22:48:30.065000Z TestFramework (INFO): Should not import a ranged descriptor that includes xpriv into a watch-only wallet
  2024-04-01T22:48:30.070000Z TestFramework (INFO): Should not import a descriptor with hardened derivations when private keys are disabled
  2024-04-01T22:48:30.108000Z TestFramework (INFO): Verify we can only extend descriptor's range
  2024-04-01T22:48:30.364000Z TestFramework (INFO): Check we can change descriptor internal flag
  2024-04-01T22:48:30.536000Z TestFramework (INFO): Key ranges should be imported in order
  2024-04-01T22:48:30.708000Z TestFramework (INFO): Check we can change next_index
  2024-04-01T22:48:30.838000Z TestFramework (INFO): Check imported descriptors are not active by default
  2024-04-01T22:48:30.870000Z TestFramework (INFO): Check can activate inactive descriptor
  2024-04-01T22:48:30.903000Z TestFramework (INFO): Check can deactivate active descriptor
  2024-04-01T22:48:30.924000Z TestFramework (INFO): Verify activation state is persistent
  2024-04-01T22:48:30.973000Z TestFramework (INFO): Should import a descriptor with a WIF private key as spendable
  2024-04-01T22:48:30.987000Z TestFramework (INFO): Test can import same descriptor with private key twice
  2024-04-01T22:48:32.173000Z TestFramework (INFO): Test that multisigs can be imported, signed for, and getnewaddress'd
  2024-04-01T22:48:43.803000Z TestFramework (INFO): Multisig with distributed keys
  2024-04-01T22:48:48.895000Z TestFramework (INFO): We can create and use a huge multisig under P2WSH
  2024-04-01T22:49:05.628000Z TestFramework (INFO): Under P2SH, multisig are standard with up to 15 compressed keys
  2024-04-01T22:49:20.258000Z TestFramework (INFO): Amending multisig with new private keys
  2024-04-01T22:49:23.306000Z TestFramework (INFO): Combo descriptors cannot be active
  2024-04-01T22:49:23.313000Z TestFramework (INFO): Descriptors with no type cannot be active
  2024-04-01T22:49:23.348000Z TestFramework (INFO): Test importing a descriptor to an encrypted wallet
  2024-04-01T22:49:43.957000Z TestFramework (ERROR): Assertion failed
  Traceback (most recent call last):
    File "/home/chris/Documents/Code/bitcoin-core/test/functional/test_framework/test_framework.py", line 132, in main
      self.run_test()
    File "/home/chris/Documents/Code/bitcoin-core/test/functional/wallet_importdescriptors.py", line 691, in run_test
      with self.nodes[0].assert_debug_log(expected_msgs=["Rescan started from block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206... (slow variant inspecting all blocks)"], timeout=5):#10):
    File "/nix/store/rac8pxbi1vapwrlqzbrkycbyg521djzw-python3-3.11.6/lib/python3.11/contextlib.py", line 144, in __exit__
      next(self.gen)
    File "/home/chris/Documents/Code/bitcoin-core/test/functional/test_framework/test_node.py", line 493, in assert_debug_log
      self._raise_assertion_error(f'Expected messages "{expected_msgs}" found too late, took {now - start:.1f} seconds, {((now - start) / (time_end - start)) - 1:.1%} over the given limit. Log:\n\n{print_log}\n\n')
    File "/home/chris/Documents/Code/bitcoin-core/test/functional/test_framework/test_node.py", line 188, in _raise_assertion_error
      raise AssertionError(self._node_msg(msg))
  AssertionError: [node 0] Expected messages "['Rescan started from block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206... (slow variant inspecting all blocks)']" found too late, took 5.4 seconds, 8.9% over the given limit. Log:

   - 2024-04-01T22:49:33.066512Z [http] [httpserver.cpp:306] [http_request_cb] [http] Received a POST request for /wallet/encrypted_wallet from 127.0.0.1:47658
   - 2024-04-01T22:49:33.066668Z [httpworker.0] [rpc/request.cpp:187] [parse] [rpc] ThreadRPCServer method=importdescriptors user=__cookie__
   - 2024-04-01T22:49:33.070999Z [httpworker.0] [wallet/sqlite.cpp:57] [TraceSqlCallback] [/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/node0/regtest/wallets/encrypted_wallet/wallet.dat] SQLite Statement: INSERT INTO main VALUES(?, ?)
   - 2024-04-01T22:49:33.071061Z [httpworker.0] [wallet/sqlite.cpp:57] [TraceSqlCallback] [/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/node0/regtest/wallets/encrypted_wallet/wallet.dat] SQLite Statement: DELETE FROM main WHERE key = ?
   - 2024-04-01T22:49:33.071137Z [httpworker.0] [wallet/sqlite.cpp:57] [TraceSqlCallback] [/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/node0/regtest/wallets/encrypted_wallet/wallet.dat] SQLite Statement: BEGIN TRANSACTION
   - 2024-04-01T22:49:33.074190Z [httpworker.0] [wallet/sqlite.cpp:57] [TraceSqlCallback] [/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/node0/regtest/wallets/encrypted_wallet/wallet.dat] SQLite Statement: INSERT or REPLACE into main values(?, ?)
   - 2024-04-01T22:49:33.075564Z [httpworker.0] [wallet/sqlite.cpp:57] [TraceSqlCallback] [/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/node0/regtest/wallets/encrypted_wallet/wallet.dat] SQLite Statement: INSERT or REPLACE into main values(?, ?)
  ...<thousands of almost identical lines>...
   - 2024-04-01T22:49:38.416139Z [httpworker.0] [wallet/sqlite.cpp:57] [TraceSqlCallback] [/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/node0/regtest/wallets/encrypted_wallet/wallet.dat] SQLite Statement: INSERT or REPLACE into main values(?, ?)
   - 2024-04-01T22:49:38.416528Z [httpworker.0] [wallet/sqlite.cpp:57] [TraceSqlCallback] [/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/node0/regtest/wallets/encrypted_wallet/wallet.dat] SQLite Statement: INSERT or REPLACE into main values(?, ?)
   - 2024-04-01T22:49:38.427946Z [httpworker.0] [wallet/sqlite.cpp:57] [TraceSqlCallback] [/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/node0/regtest/wallets/encrypted_wallet/wallet.dat] SQLite Statement: COMMIT TRANSACTION
   - 2024-04-01T22:49:38.429778Z [httpworker.0] [wallet/sqlite.cpp:57] [TraceSqlCallback] [/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/node0/regtest/wallets/encrypted_wallet/wallet.dat] SQLite Statement: INSERT or REPLACE into main values(?, ?)
   - 2024-04-01T22:49:38.429916Z [httpworker.0] [wallet/sqlite.cpp:57] [TraceSqlCallback] [/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/node0/regtest/wallets/encrypted_wallet/wallet.dat] SQLite Statement: INSERT or REPLACE into main values(?, ?)
   - 2024-04-01T22:49:38.430001Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [encrypted_wallet] Setting spkMan to active: id = c6149b35399517457b0b1d8ccdd7efda25a2f20fc7f8167adda8e79b10e260b7, type = legacy, internal = false
   - 2024-04-01T22:49:38.430134Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [encrypted_wallet] RescanFromTime: Rescanning last 329 blocks
   - 2024-04-01T22:49:38.430170Z [httpworker.0] [wallet/wallet.h:933] [WalletLogPrintf] [encrypted_wallet] Rescan started from block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206... (slow variant inspecting all blocks)
   - 2024-04-01T22:49:38.441914Z [httpworker.0] [wallet/scriptpubkeyman.h:258] [WalletLogPrintf] [encrypted_wallet] MarkUnusedAddresses: Detected a used keypool item at index 4000, mark all keypool items up to this item as used

  2024-04-01T22:49:44.029000Z TestFramework (INFO): Stopping nodes
  2024-04-01T22:49:44.132000Z TestFramework (WARNING): Not cleaning up dir /mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98
  2024-04-01T22:49:44.132000Z TestFramework (ERROR): Test failed. Test logging available at /mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98/test_framework.log
  2024-04-01T22:49:44.132000Z TestFramework (ERROR):
  2024-04-01T22:49:44.133000Z TestFramework (ERROR): Hint: Call /home/chris/Documents/Code/bitcoin-core/test/functional/combine_logs.py '/mnt/tmp/test_runner_₿_🏃_20240402_004231/wallet_importdescriptors_98' to consolidate all logs
  2024-04-01T22:49:44.133000Z TestFramework (ERROR):
  2024-04-01T22:49:44.133000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
  2024-04-01T22:49:44.133000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
  2024-04-01T22:49:44.133000Z TestFramework (ERROR):

  stderr:

  Remaining jobs: [feature_pruning.py, feature_dbcrash.py, feature_assumeutxo.py, rpc_scantxoutset.py, feature_coinstatsindex.py, p2p_node_network_limited.py --v1transport, p2p_node_network_limited.py --v2transport, feature_config_args.py]
  298/305 - p2p_node_network_limited.py --v1transport passed, Duration: 24 s
  ```

  </details>

  ## Related

  Almost identical timeout in `feature_index_prune.py` in bitcoin#27091 on MacOS, and for `wallet_importdescriptors.py --descriptors` in bitcoin#27282 on Alpine & CI.

ACKs for top commit:
  maflcko:
    lgtm ACK 49c0b8b
  tdb3:
    ACK for 49c0b8b
  itornaza:
    approach ACK 49c0b8b
  BrandonOdiwuor:
    crACK 49c0b8b

Tree-SHA512: f62ade74701588d76bfe838b7e7bbda1db38fd98688fd5d13c2c008064027add2ee9d053dee602d84919fab4c9bf53183c31819d94a6174066f237d0f6a62086
hebasto added a commit that referenced this pull request Aug 15, 2024
784a87e fixup! doc: Update for CMake-based build system (Hennadii Stepanov)

Pull request description:

  On the master branch, `make check` generates a `foo_tests.log` file for each `foo_tests.cpp`.  These log files are only printed when a test fails. Since no one has raised concerns about the log file [renaming](bitcoin#19385 (comment)) in bitcoin#19385, these files appear to serve no other purpose.

  CTest provides its own mechanisms for logging failed tests, making the creation of `foo_tests.log` files unnecessary.

  This PR documents these CTest logging mechanisms.

  An example of output with a mocked test error:
  ```
  $ ctest --test-dir build -j 16 --output-on-failure
  Internal ctest changing into directory: /home/hebasto/git/bitcoin/build
  Test project /home/hebasto/git/bitcoin/build
          Start  10: amount_tests
          Start   6: tests
          Start   5: noverify_tests
          Start 120: coinselector_tests
          Start   7: exhaustive_tests
          Start  29: coins_tests
          Start 130: wallet_tests
          Start  75: random_tests
          Start 102: transaction_tests
          Start   1: util_test_runner
          Start 133: walletload_tests
          Start  31: coinstatsindex_tests
          Start  63: net_tests
          Start  35: crypto_tests
          Start  27: checkqueue_tests
          Start  56: miner_tests
    1/133 Test  #10: amount_tests .........................***Failed    0.02 sec
  Running 4 test cases...
  ./src/test/amount_tests.cpp(19): error: in "amount_tests/MoneyRangeTest": check MoneyRange(MAX_MONEY) == false has failed [true != false]

  *** 1 failure is detected in the test module "Bitcoin Core Test Suite"

          Start 113: validation_block_tests
    2/133 Test #113: validation_block_tests ...............   Passed    1.02 sec
  < snip >
  133/133 Test   #6: tests ................................   Passed  100.94 sec

  99% tests passed, 1 tests failed out of 133

  Total Test time (real) = 100.95 sec

  The following tests FAILED:
   10 - amount_tests (Failed)
  Errors while running CTest
  ```

  ---

  A question for reviewers: Do we really need the `--log_level=test_suite` option for these logs?

ACKs for top commit:
  vasild:
    ACK 784a87e

Tree-SHA512: bfe4ab2c7f9002584a41efa3607c911b6c635720ae5a6d080294b3240c4df546d25e5ac0d667881b836f6c47f2e55915e093ca14765951c40d4856482b52a9fd
hebasto pushed a commit that referenced this pull request Nov 2, 2024
…et_create_transaction

5a26cf7 fuzz: fix `implicit-integer-sign-change` in wallet_create_transaction (brunoerg)

Pull request description:

  This PR limites the value of `m_confirm_target` to avoid `implicit-integer-sign-change`:
  ```
  /ci_container_base/src/wallet/fees.cpp:58:58: runtime error: implicit conversion from type 'unsigned int' of value 4294967292 (32-bit, unsigned) to type 'int' changed the value to -4 (32-bit, signed)
      #0 0x55b6fd26c021 in wallet::GetMinimumFeeRate(wallet::CWallet const&, wallet::CCoinControl const&, FeeCalculation*) ci/scratch/build-x86_64-pc-linux-gnu/src/wallet/./src/wallet/fees.cpp:58:58
      #1 0x55b6fd3ef5ca in wallet::CreateTransactionInternal(wallet::CWallet&, std::vector<wallet::CRecipient, std::allocator<wallet::CRecipient>> const&, std::optional<unsigned int>, wallet::CCoinControl const&, bool) ci/scratch/build-x86_64-pc-linux-gnu/src/wallet/./src/wallet/spend.cpp:1101:49
      #2 0x55b6fd3ebea5 in wallet::CreateTransaction(wallet::CWallet&, std::vector<wallet::CRecipient, std::allocator<wallet::CRecipient>> const&, std::optional<unsigned int>, wallet::CCoinControl const&, bool) ci/scratch/build-x86_64-pc-linux-gnu/src/wallet/./src/wallet/spend.cpp:1382:16
      #3 0x55b6fccbc154 in wallet::(anonymous namespace)::wallet_create_transaction_fuzz_target(std::span<unsigned char const, 18446744073709551615ul>) ci/scratch/build-x86_64-pc-linux-gnu/src/test/fuzz/./src/wallet/test/fuzz/spend.cpp:99:11
      #4 0x55b6fccda45d in std::function<void (std::span<unsigned char const, 18446744073709551615ul>)>::operator()(std::span<unsigned char const, 18446744073709551615ul>) const /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:591:9
      #5 0x55b6fccda45d in LLVMFuzzerTestOneInput ci/scratch/build-x86_64-pc-linux-gnu/src/test/fuzz/util/./src/test/fuzz/fuzz.cpp:211:5
      #6 0x55b6fc368484 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1c8a484) (BuildId: d11f8692b05f02b5a14b6e7579598b426e3144c5)
      #7 0x55b6fc367b79 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) (/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1c89b79) (BuildId: d11f8692b05f02b5a14b6e7579598b426e3144c5)
      #8 0x55b6fc369796 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1c8b796) (BuildId: d11f8692b05f02b5a14b6e7579598b426e3144c5)
      #9 0x55b6fc369ca7 in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1c8bca7) (BuildId: d11f8692b05f02b5a14b6e7579598b426e3144c5)
      #10 0x55b6fc35719f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1c7919f) (BuildId: d11f8692b05f02b5a14b6e7579598b426e3144c5)
      #11 0x55b6fc381826 in main (/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1ca3826) (BuildId: d11f8692b05f02b5a14b6e7579598b426e3144c5)
      #12 0x7f934c6661c9  (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 6d64b17fbac799e68da7ebd9985ddf9b5cb375e6)
      #13 0x7f934c66628a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 6d64b17fbac799e68da7ebd9985ddf9b5cb375e6)
      #14 0x55b6fc34c184 in _start (/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/src/test/fuzz/fuzz+0x1c6e184) (BuildId: d11f8692b05f02b5a14b6e7579598b426e3144c5)

  SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change /ci_container_base/src/wallet/fees.cpp:58:58
  MS: 0 ; base unit: 0000000000000000000000000000000000000000
  0x2e,0x1,0xb0,0xb8,0x0,0xff,0xff,0xff,0xff,0x60,0x14,0x22,0xff,0xff,0xff,0xff,0xff,0xfd,0xff,0xff,0xff,0xff,0xff,0x7e,0xf9,0x41,0x8,0x2b,0x17,0x58,0xb,0x17,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,0xf9,0x41,0x8,0x2b,0x17,0x58,0xb,
  .\001\260\270\000\377\377\377\377`\024\"\377\377\377\377\377\375\377\377\377\377\377~\371A\010+\027X\013\027\374\377\377\377\377\377\377~\371A\010+\027X\013
  artifact_prefix='./'; Test unit written to ./crash-5627f57ffba7568a500f8379f62c3338978b43f2
  Base64: LgGwuAD/////YBQi///////9//////9++UEIKxdYCxf8////////fvlBCCsXWAs=
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 5a26cf7
  dergoegge:
    utACK 5a26cf7

Tree-SHA512: a1b129d81d42350cf85ff6fb95cd6982b6aac88467a526ee4b3c9b3313af2f7952c5dfa9886f455756faba399d8356b6c318d7ab2d6318e08fea838bee90b2fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants